package com.think.admin.model.param.resource;

import com.think.common.cons.Regex;
import com.think.common.convert.Convert;
import com.think.common.validation.CreateOrUpdate;
import com.think.dao.enums.ResourcePermissionTypeEnum;
import com.think.dao.enums.ResourceTypeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * <p>
 * 资源：新增或者修改
 * </p>
 *
 * @author: xwj
 * @data: 2019-04-08
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class ResourceParam extends Convert {

    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    private String id;

    /**
     * 资源类型
     */
    @NotNull(groups = {CreateOrUpdate.class}, message = "资源类型不能为空")
    private ResourceTypeEnum type;

    /**
     * 上级资源ID
     */
    private String parentId;

    /**
     * 资源名
     */
    @NotBlank(groups = {CreateOrUpdate.class}, message = "资源名不能为空")
    private String name;

    /**
     * 图标
     */
    private String icon;

    /**
     * 地址
     */
    private String uri;

    /**
     * 权限表达式
     */
    private String permission;

    /**
     * 权限类型
     */
    @NotNull(groups = {CreateOrUpdate.class}, message = "权限类型不能为空")
    private ResourcePermissionTypeEnum permissionType;

    /**
     * 序号
     */
    @Pattern(groups = {CreateOrUpdate.class}, regexp = Regex.NUMBER, message = "资源序号不正确")
    private String sort;

    /**
     * 备注
     */
    private String remark;
}
